<?php

namespace app\admin\model\express;

use think\Model;


class Withdraw extends Model
{

    

    

    // 表名
    protected $name = 'express_withdraw';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'with_type_text',
        'status_text'
    ];
    

    
    public function getWithTypeList()
    {
        return ['wechat' => __('With_type wechat'), 'alipay' => __('With_type alipay'), 'bank' => __('With_type bank')];
    }

    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];
    }


    public function getWithTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['with_type']) ? $data['with_type'] : '');
        $list = $this->getWithTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function expressuser()
    {
        return $this->belongsTo('User', 'express_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function payaccount()
    {
        return $this->belongsTo('Payaccount', 'account_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
